The present invention relates to the field of computer memory management. Specifically, the present invention relates to a method and system for an operating system to manage compressed memory.
As the gap between hard drive access time and memory access time increases, it is increasingly desirable to locate more data in memory. This is increasingly important because the size of applications and data sets are increasing at a faster rate than the density of main memory. Furthermore, systems with multiprocessors may have many programs running simultaneously with each program having a relatively small number of pages of instructions and data in main memory. Hence, page faults may occur frequently. One way to increase the effective storage capacity of main memory is to compress the contents of main memory. However, conventional computer systems may be unable to efficiently manage the compressed data in main memory.
One conventional method that provides for compressed data in main memory is to indicate to the operating system at boot-up time that there is more physical memory than actually exists. The assumption is that compression will allow for the physical memory to act larger than it actually is. However, it is possible that physical memory can run out, if the assumption regarding compression fails. This system makes the operating system aware that memory is running out by, for example, adjusting a low memory indicator. A set of registers exist in the memory controller to control and monitor the compression status of the system. If the registers report that physical memory is becoming too full, an interrupt can be generated to warn the operating system of the impending out-of-memory condition. When the physical memory utilization gets too high, the low memory indicator is adjusted.
Unfortunately, in this conventional system, at times physical memory utilization may rapidly increase. Because of the limited speed of the swap disk, the system may need to temporarily stall applications from executing. This provides the system with the time it needs to free physical memory by swapping memory pages out to a hard drive, however, with the expense of stalling the execution of applications.
While such methods may allow for increased memory capacity, certain inefficiencies may result. For example, the operating system and the system controlling memory access and data compression may not have information known to the other system. Hence, there may not be an entity which is capable of intelligently planning in which memory to store a given piece of data. For example, if data being accessed has been compressed, the data must be decompressed before the data is read. Unfortunately, the operating system in most conventional systems does not know whether the data has been compressed. Therefore, the extra latency associated with the decompression is unexpected by the operating system.
Accordingly, the present invention provides a method and system for allowing an operating system to control the movement and compression/decompression of data in main memory. The present invention provides a single entity with knowledge of the latency to access specific data, wherein intelligent data storage decisions may be made. The present invention minimizes the need to access data on a slow access storage medium, such as a hard drive. These and other advantages of the present invention will become apparent within discussions of the present invention herein.
A method for adding compressed page tables to an operating system is disclosed. An embodiment provides for a method in which an operating system has control of the compression and decompression of data and where the data is stored. When a data access is desired, the operating system accesses a table specifying the physical memory location of uncompressed data to determine if specified data is in uncompressed memory. If the data is not in the uncompressed memory, the method of this embodiment accesses a table specifying the physical memory location of data in compressed memory to determine if the data is in the compressed memory. Then, this embodiment decompresses the data, if necessary, and returns the data.
In other embodiments further steps are performed, including accessing a translation look-aside buffer before accessing the uncompressed page table, and accessing a page directory table to locate data on a hard drive in the event of a page fault. Furthermore, the table look-ups may be performed in parallel, or in other orders.